package com.trace.app.controller;


import com.trace.app.entity.Category;
import com.trace.app.entity.ResponseResult;
import com.trace.app.service.CategoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Category)表控制层
 *
 * @author lionkliu
 * @since 2024-04-02 12:38:15
 */
@RestController
@RequestMapping("category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;

    @GetMapping("/getCategory")
    public ResponseResult getCategory() {
        return categoryService.getCategory();
    }

    @GetMapping("/getLabelValue")
    public ResponseResult getLabelValue() {
        return categoryService.getLabelValue();
    }
    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {
        return categoryService.selectPage(pageNum, pageSize);
    }

    @GetMapping("/list")
    public ResponseResult list() {
        return ResponseResult.okResult(categoryService.list());
    }

    @GetMapping("{id}")
    public ResponseResult selectOne(@PathVariable Integer id) {
        return categoryService.selectOne(id);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody Category category) {
        return categoryService.insertOne(category);
    }

    @PutMapping
    public ResponseResult update(@RequestBody Category category) {
        return categoryService.updateOne(category);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return categoryService.deleteById(id);
    }

}
